<?php
require_once dirname(__FILE__)."/base_model.php";
class groups extends base_model {

	const GROUPS_TABLE	= "table_groups";
	const MEMBERS_TABLE	= "table_workers";

	public function __construct() {
		parent::__construct();
	}

	//工作组
	public function getAllGroups() {
		$this->db->select('group_id, group_name');
		$this->db->from(self::GROUPS_TABLE);
		return $this->db->get()->result_array();
	}

	//根据组ID取得组成员
	public function getGroupMembersByGroupId($group_id)
	{
		$this->db->where('worker_groupid', $group_id);
		$this->db->from(self::MEMBERS_TABLE);
		$this->db->order_by('is_charger', 'DESC');
		return $this->db->get()->result_array();
	}
	
	public function getGroupById($gId)
	{
		$this->db->where('group_id', $gId);
		$this->db->from(self::GROUPS_TABLE);
		return $this->db->get()->row_array();
	}
}